﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace AIRO.Devices
{
    namespace Solenoid
    {
        [Guid("C713D5F5-7FC7-44fd-A3DC-F5948DACA6DB")]        
        public enum SolenoidState:int
        {
            Idle,
            Paused,
            Running,
            Error,
            QuenchDetected,
            HeatingPersistentSwitch            

        }

        [Guid("4F6044CA-5060-422b-870C-AB0E4C3BC3B3")]
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("AIRO.Devices.Solenoid.ProgressEventArgs")]
        public class ProgressEventArgs : EventArgs
        {
            private double _field;
            public ProgressEventArgs(double field)
            {
                this._field = field;
            }
            public double Field
            {
                get
                {
                    return _field;
                }
            }
        }

        [Guid("EDBF0DF2-003F-49e3-AFFD-91FB357715B8")]
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("AIRO.Devices.Solenoid.FieldSetEventArgs")]
        public class FieldSetEventArgs : EventArgs
        {
            private double _field;
            public FieldSetEventArgs(double field)
            {
                this._field = field;
            }
            public double Field
            {
                get
                {
                    return _field;
                }
            }

        }

        [Guid("0A3772A4-19FC-4826-834B-54FB2E3B642A")]
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("AIRO.Devices.Solenoid.StateChangedEventArgs")]
        public class StateChangedEventArgs : EventArgs
        {

            private SolenoidState _newState;
            
            public StateChangedEventArgs(SolenoidState newState)
            {
                this._newState = newState;
            }

            public SolenoidState State
            {
                get
                {
                    return _newState;
                }
            }
        }

        [Guid("5219B909-D0E9-485c-BFEF-2C329FC73A1B")]
        [InterfaceType(ComInterfaceType.InterfaceIsDual)]
        public interface ISolenoid
        { 
            [DispId(1)]
            SolenoidState State{ get; }
            [DispId(2)]
            double MagnetField { get; }
            [DispId(3)]
            void BeginGotoField(double field);            
            [DispId(4)]
            void Cancel();
            [DispId(5)]
            event EventHandler<StateChangedEventArgs> StateChangedEvent;
            [DispId(6)]
            event EventHandler<FieldSetEventArgs> FieldSetEvent;
            [DispId(7)]
            event EventHandler<ProgressEventArgs> ProgressEvent;
        }
    }
}
